* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #ffffff;
    color: #333333;
    display: flex;
    flex-direction: column;
}

html, body {
    height: 100%;
    overflow: hidden; /* 如需限制外层滚动 */
}

.header {
    background-color: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.user-auth-section {
    position: absolute;
    top: 15px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 8px 15px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(74, 85, 104, 0.1);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: #2d3748;
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.auth-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.login-btn {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.3);
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.4);
}

.register-btn {
    background: rgba(255, 255, 255, 0.9);
    color: #4299e1;
    border: 1px solid #4299e1;
}

.register-btn:hover {
    background: #4299e1;
    color: white;
}

.logout-btn {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 101, 101, 0.3);
}

.logout-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 101, 101, 0.4);
}

.user-menu {
    position: relative;
    display: inline-block;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    min-width: 180px;
    padding: 8px 0;
    margin-top: 5px;
    display: none;
    z-index: 1001;
}

.user-dropdown.show {
    display: block;
}

.dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #2d3748;
    text-decoration: none;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #f7fafc;
}

.dropdown-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 8px 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .user-auth-section {
        position: static;
        justify-content: flex-end;
        padding: 10px 20px;
        background: rgba(255, 255, 255, 0.95);
        border-bottom: 1px solid rgba(74, 85, 104, 0.1);
    }

    .user-info {
        background: transparent;
        box-shadow: none;
        border: none;
    }

    .auth-buttons {
        flex-direction: column;
        gap: 5px;
    }

    .auth-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

.logo {
    font-size: 18px;
    font-weight: 600;
    color: #333333;
}

.lab-info {
    font-size: 14px;
    color: #6b7280;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
}

.message.user {
    background-color: #f0f9ff;
    padding: 15px 20px;
    margin: 0 -20px 20px -20px;
}

.message.assistant {
    background-color: #f9fafb;
    padding: 15px 20px;
    margin: 0 -20px 20px -20px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.user-avatar {
    background-color: #3b82f6;
    color: white;
}

.assistant-avatar {
    background-color: #10b981;
    color: white;
}

.message-content {
    flex: 1;
    line-height: 1.6;
}

.input-area {
    padding: 20px;
    background-color: #ffffff;
    border-top: 1px solid #e5e7eb;
}

.input-container {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.message-input {
    width: 100%;
    padding: 12px 50px 12px 15px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background-color: #ffffff;
    color: #333333;
    font-size: 16px;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    outline: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.send-button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background-color: #3b82f6;
    border: none;
    border-radius: 4px;
    color: white;
    width: 35px;
    height: 35px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.send-button:hover {
    background-color: #2563eb;
}

.send-button:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.welcome-message {
    text-align: center;
    margin-top: 100px;
    color: #6b7280;
}

.welcome-title {
    font-size: 24px;
    margin-bottom: 10px;
    color: #333333;
}

.footer {
    text-align: center;
    padding: 20px;
    background-color: #f9fafb;
    color: #6b7280;
    font-size: 16px;
    border-top: 1px solid #e5e7eb;
}

.typing-indicator {
    display: none;
    padding: 15px 20px;
    background-color: #f9fafb;
    margin: 0 -20px 20px -20px;
}

.typing-dots {
    display: flex;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #6b7280;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* 左侧功能选择面板样式 */
.function-sidebar {
    flex: 0 0 250px;
    background: linear-gradient(135deg, #e8f2ff 0%, #f0f4ff 100%);
    color: #4a5568;
    padding: 20px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    height: calc(100vh - 150px);
}

.function-sidebar h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 18px;
    text-align: center;
    color: #2d3748;
    text-shadow: none;
}

.function-item {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(74, 85, 104, 0.15);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.function-item:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-color: rgba(74, 85, 104, 0.25);
}

.function-item.active {
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.2);
}

.function-item h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.function-item p {
    margin: 0;
    font-size: 12px;
    opacity: 0.7;
    line-height: 1.4;
    color: #718096;
}

.function-icon {
    font-size: 18px;
}

.history-sidebar {
    max-width: 300px;
    border-right: 1px solid #ccc;
    background-color: #f7f7f7;
}

.conversation-preview {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
}

.conversation-preview:hover {
    background-color: #eaeaea;
}

.conversation-title {
    font-weight: bold;
    font-size: 16px;
}

.conversation-last {
    font-size: 14px;
    color: #555;
}

/* 美化版本 2 - 毛玻璃效果 */
.glass-copy-btn {
    background: #3b82f6;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 7px;
    padding: 5px 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: wheat;
    position: relative;
    overflow: hidden;
}

.glass-copy-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transition: all 0.4s ease;
    transform: translate(-50%, -50%);
}

.glass-copy-btn:hover::after {
    width: 200px;
    height: 200px;
}

.glass-copy-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.glass-copy-btn svg {
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

.glass-copy-btn:hover svg {
    transform: rotate(5deg) scale(1.1);
}


/* 历史对话侧边栏样式 */
.history-sidebar {
    width: 300px;
    background: white;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

.history-sidebar.collapsed {
    width: 60px;
}

.history-header {
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-sidebar.collapsed .history-header {
    padding: 20px 10px;
}

.history-header h3 {
    font-size: 16px;
    color: #2d3748;
    font-weight: 600;
    transition: all 0.3s ease;
}

.history-sidebar.collapsed .history-header h3 {
    font-size: 0;
}

.history-toggle {
    background: #4299e1;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.history-toggle:hover {
    background: #3182ce;
    transform: scale(1.1);
}

.conversation-list {
    padding: 10px;
    overflow-y: auto;
    height: 75vh; /* 或者指定最大高度 */
}

.conversation-preview {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.conversation-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #4299e1;
}

.conversation-preview.active {
    border-color: #4299e1;
    background: #f7fafc;
}

.conversation-title {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 5px;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.conversation-title::before {
    content: "\1F4AC"; /* 💬 的 Unicode 编码 */
    margin-right: 8px;
}

.conversation-last {
    font-size: 12px;
    color: #718096;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.conversation-time {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 5px;
}

.history-sidebar.collapsed .conversation-list {
    padding: 5px;
}

.history-sidebar.collapsed .conversation-preview {
    padding: 10px 5px;
    text-align: center;
}

.history-sidebar.collapsed .conversation-title {
    font-size: 0;
}

.history-sidebar.collapsed .conversation-title::before {
    content: '💬';
    margin-right: 0;
    font-size: 16px;
}

.history-sidebar.collapsed .conversation-last,
.history-sidebar.collapsed .conversation-time {
    display: none;
}


/* 响应式设计 */
@media (max-width: 768px) {
    .function-sidebar {
        width: 60px;
        padding: 20px 10px;
    }

    .history-sidebar {
        width: 60px;
        height: 100vh;               /* 保证侧边栏本身不随内容变高 */
    }

    .function-sidebar h3,
    .history-header h3 {
        font-size: 0;
    }

    .function-item p,
    .conversation-last,
    .conversation-time {
        display: none;
    }
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
    }

    .lab-info {
        margin-top: 5px;
    }

    .messages-area {
        padding: 15px;
    }

    .input-area {
        padding: 15px;
    }

    .function-sidebar {
        flex: 0 0 60px;
        padding: 10px 5px;
    }

    .function-sidebar h3 {
        writing-mode: vertical-rl;
        text-orientation: mixed;
        margin: 0;
        font-size: 14px;
    }

    .function-item {
        padding: 8px;
        margin-bottom: 8px;
    }

    .function-item h4,
    .function-item p {
        display: none;
    }

    .function-icon {
        font-size: 20px;
        text-align: center;
        width: 100%;
    }
}